using System;
using System.Windows.Markup;
using Microsoft.Practices.Unity;
using InjectionMember=Common.Unity.Configuration.InjectionMember;

namespace Common.Unity.Extensions.Configuration
{
	[ContentProperty( "Instance" )]
	public class PolicyInstance : InjectionMember
	{
		public Type Type { get; set; }

		public PolicyCreatorBase Instance { get; set; }

		public override Microsoft.Practices.Unity.InjectionMember Create( IUnityContainer container, Type targetType )
		{
			var policy = Instance.PolicyInstance;
			var result = new PolicyInjection( Type ?? policy.GetType(), policy );
			return result;
		}
	}
}